
#include <BookingRecord.h>

namespace AirlineRes
{


BookingRecord::BookingRecord
(
  int _flightID,
  int _customerID,
  BookingStatus _status,
  BookingClass  _class
)
: m_flightID( _flightID ),
  m_customerID( _customerID ),
  m_status( _status ),
  m_class( _class )
{
}

Record::RecordIOResult BookingRecord::LoadRecord( std::istream& _stream )
{
  int bStatus;
  int bClass;
  // TODO: Validation.
  _stream >> std::skipws;   // Skip whitespace.
  _stream >> m_id >> m_flightID >> m_customerID >> bStatus >> bClass;
  _stream >> std::noskipws; // Reset stream state. 

  m_status = (BookingStatus)bStatus;
  m_class = (BookingClass)bClass;

  return Record::RecordIOResult_Success;
}

Record::RecordIOResult BookingRecord::WriteRecord( std::ostream& _stream ) const
{
  _stream
    << m_id << " "
    << m_flightID << " "
    << m_customerID << " "
    << m_status << " "
    << m_class << "\n";

  return Record::RecordIOResult_Success;
}
    

} // namespace AirlineRes
